<!doctype html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html;charset=uft-8" />
    <meta name="viewport"   content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0" />
    <title>塑料行情</title>
    <style>
        .xAxis >.tickLabel
        {
            width: 38px;
            margin-top: 10px;
            -o-transform:rotate(-45deg);
            -moz-transform:rotate(-45deg);
            -webkit-transform:rotate(-45deg);
            filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
        }

    </style>
    <link href="/res/quote/scss/quote.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div class="title">
        <h2>{$result['title']}</h2>
        <p><span>时间：<em>{$result['addtime']}</em></span><span> 阅读量：<em>{$result['views']}</em></span></p>
    </div>
    <div class="num_data">
        <h3 class="sub_title">行情数据</h3>
        <ul>
            <li class="fl" style="border-right: 1px solid #efefef;">
                <span>品名：{$result['product_name']}</span>
                <span>昨日价格：{$result['yesterday_price']}<em>（元/吨）</em></span>
                <span>今日价格：{$result['today_price']}<em>（元/吨）</em></span>
            </li>
            <li class="fr">
                <span>厂家：{$result['factory_name']}</span>
                <span>牌号：{$result['brand_name']}</span>

                {if $result['float_price']>0}
                  <strong >张跌：{$result['float_price']}</strong>
                {else}
                  <strong style="color:#4cae4c">张跌：{$result['float_price']}</strong>
                {/if}
            </li>
        </ul>
    </div>
    <div class="trend">
        <h3 class="sub_title">行情趋势</h3>
        <span class="unit">价格 元/吨</span>
        <div id="chart"></div>
        <p style="margin-bottom: 10px;">
           {if $result['content']!=''}
               $result['content']
           {/if}
        </p>
        <p class="blank"></p>
    </div>
    <div class="foucs">
        <h3><img src="/res/quote/img/quote_logo.png"><span>塑料报价</span></h3>
        <p>“塑料报价”专注于成为塑化行业用户的服务管家，如果客官喜欢我们请长按下方二维码关注，每天持续为您提供最精准的行情报价！</p>

        <div class="qr_code"><img src="/res/quote/img/wx_follow.png"></div>

    </div>
</body>
</html>

<script src="/res/js/framework/jquery.min.js"></script>
<script src="/res/js/framework/flot-chart/jquery.flot.js"></script>
<script src="/res/js/framework/flot-chart/jquery.flot.time.js"></script>
<script src="/res/js/framework/flot-chart/jquery.flot.symbol.js"></script>
<script>
    Date.prototype.Format = function (fmt) { //author: meizz
        var o = {
            "M+": this.getMonth() + 1, //月份
            "d+": this.getDate(), //日
            "h+": this.getHours(), //小时
            "m+": this.getMinutes(), //分
            "s+": this.getSeconds(), //秒
            "q+": Math.floor((this.getMonth() + 3) / 3), //季度
            "S": this.getMilliseconds() //毫秒
        };
        if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
            if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        return fmt;
    };
</script>


<script>
    var x_arr = [{$trendChartData['x_arr']}];
    var y_arr = [{$trendChartData['y_arr']}];

    if (x_arr.length>=1) {

        showPlot(x_arr);
    }else{

        $("#chart").html('请输入牌号，查看行情趋势！');
    }
    function gd(year, month, day) {
        return new Date(year, month-1, day).Format("MM-dd");
    }

    function getPositionForData(plot,cell){
        var obj = plot.getData()[0],
            dx = cell[0], dy = cell[1],
            ox = plot.offset().left, oy = plot.offset().top,
            _x = obj.xaxis.p2c(dx) + ox, _y = obj.yaxis.p2c(dy) + oy;
        return {x:_x,y:_y}
    }

    function showPlot(x_arr) {


        var plot = $.plot("#chart", [y_arr], {
            xaxis: {
                ticks:x_arr
            },
            series: {
                lines: { show: true},
                points: {
                    show: true,
                    lineWidth: 2,
                    fill: true,
                    fillColor: "#ffffff",
                    symbol: "circle",
                    radius: 3
                }
            },
            grid: {
                hoverable: true,
                clickable: true,
                tickColor: "#f9f9f9",
                borderWidth: 1,
                borderColor: "#eeeeee"
            },
            colors: ["#2dc0e8", "#0022FF"],

        });


        window.tooltip = $("<div id='tooltip'></div>").css({
            position: "absolute",
            display: "none",
            "color":"#000",
            "border-radius":"3px",
            opacity: 0.80
        }).appendTo("body");

       var cell = y_arr[y_arr.length-1],
           position = getPositionForData(plot,cell);
        showtool(position,cell[1]);
        //要先showtool()才能获取小浮窗的width和计算偏移量，再调用一次showtool()覆盖原来的位置
        var w_tool = tooltip.width();
        position.x=position.x - w_tool/2;
        showtool(position,cell[1]);

    }





    function showtool(position,item) {

        window.tooltip && (function(){
            tooltip.css({left:position.x,top:position.y}).html(item);
            var h = tooltip.height(), w = tooltip.width();
            //alert(item.dataIndex)
           if (item.dataIndex==7){
                tooltip.css({marginTop:-h/2,marginLeft:-w/2-4}).fadeIn();
            }else {
                tooltip.css({marginTop:-h-2,marginLeft:-w/2}).fadeIn();
            }

        }());


        console.info(item)
        console.info(window.tooltip)
    }

    $("#chart").bind("plotclick", function (event, pos, item) {

        if (item) {
            var temp_x=item.pageX;
            console.log(item.dataIndex)

            if(item.dataIndex==6){
                showtool({x:temp_x,y:item.pageY},item.datapoint[1]);
                var w_tool = tooltip.width()/2;
                //alert(w_tool);
                temp_x=item.pageX-w_tool;
            }
            //alert(temp_x)
            showtool({x:temp_x,y:item.pageY},item.datapoint[1]);
        } else {
            window.tooltip&&window.tooltip.fadeIn();
        }

    });

   // $(".xAxis > .tickLabel").rotate(-45);


</script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script src="/res/offer/js/jweixin-min.js"></script>
<script>
      // 注册微信分享接口
        weiXin({
            debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
            appId: '{$token.appId}', // 必填，公众号的唯一标识
            timestamp: "{$token.timestamp}", // 必填，生成签名的时间戳
            nonceStr: '{$token.nonceStr}', // 必填，生成签名的随机串
            signature: '{$token.signature}',// 必填，签名，见附录1
            title: "塑料行情", // 分享标题
            desc: "{$result['title']}", // 分享描述
            link: '{$token.url}', // 分享链接
            imgUrl: window.location.origin+"/res/offer/img/wx_share.jpg" // 分享图标
        });

</script>